package com.kunbo.cn.controller.core.reporting;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.kunbo.cn.service.core.reporting.PurchaseReportingService;
import com.kunbo.cn.service.core.reporting.SaleReportingService;
import com.kunbo.cn.util.retu.BuildBean;
import com.kunbo.cn.util.retu.BuildBean1;
import com.kunbo.cn.util.retu.Pages;
import com.kunbo.cn.util.retu.ResultBean;
import com.kunbo.cn.util.retu.ResultBean1;

/**
 *
 * @author bjl  
 * @date 2019年4月8日 
 */
@RestController
@RequestMapping("/SaleReport")
public class SaleReportingController {
	@Autowired
    private JdbcTemplate jdbcTemplate;
	@Autowired
	private SaleReportingService service;
	
	/**
	 * 销售逐车明细表
	 */
	@GetMapping("/getSalePoundList")
	public ResultBean1<Pages> getSalePoundList(
			@RequestParam("client")String client,
			@RequestParam("materiel")String materiel,//缺运输单位，物料类型 司机
			@RequestParam("wagonNumber")String wagonNumber,
			@RequestParam("trafficUnit")String trafficUnit,
			@RequestParam("driver")String driver,
			@RequestParam("matter_type")String matter_type,
			@RequestParam("shippingUnit")String shippingUnit,
			@RequestParam("start_time")String start_time,
			@RequestParam("end_time")String end_time,
			@RequestParam("page")Integer page,
			@RequestParam("pageSize")Integer pageSize
			){
		ResultBean1<Pages> result  = new ResultBean1<Pages>();
		return BuildBean1.buildResulttoPages(result, "success", "error", service.getSalePoundList1(client,materiel,wagonNumber,trafficUnit,driver,matter_type,shippingUnit,start_time,end_time,page,pageSize));
	}
	/**
	 * 销售物料统计
	 */
	/**
	 * 销售物料统计
	 */
	@GetMapping("/getSaleMatterCount")
	public ResultBean1<Pages>getSaleMatterCount(
			@RequestParam("client")String client,
			@RequestParam("materiel")String materiel,//缺运输单位，物料类型 司机
			@RequestParam("wagonNumber")String wagonNumber,
			@RequestParam("trafficUnit")String trafficUnit,
			@RequestParam("driver")String driver,
			@RequestParam("matter_type")String matter_type,
			@RequestParam("shippingUnit")String shippingUnit,
			@RequestParam("start_time")String start_time,
			@RequestParam("end_time")String end_time,
			@RequestParam("page")Integer page,
			@RequestParam("pageSize")Integer pageSize
			){
		ResultBean1<Pages> result  = new ResultBean1<Pages>();
		return BuildBean1.buildResulttoPages(result, "success", "error", service.getSaleMatterCount1(client,materiel,wagonNumber,trafficUnit,driver,matter_type,shippingUnit,start_time,end_time,page,pageSize));
	}
	
	/**
	 * 销售余量统计
	 */
	@GetMapping("/getSaleMarginCount")
	public ResultBean1<Pages> getSaleMarginCount(
			@RequestParam("client")String client,
			@RequestParam("materiel")String materiel,//缺运输单位，物料类型 司机
			@RequestParam("wagonNumber")String wagonNumber,
			@RequestParam("trafficUnit")String trafficUnit,
			@RequestParam("driver")String driver,
			@RequestParam("matter_type")String matter_type,
			@RequestParam("shippingUnit")String shippingUnit,
			@RequestParam("start_time")String start_time,
			@RequestParam("end_time")String end_time,
			@RequestParam("page")Integer page,
			@RequestParam("pageSize")Integer pageSize
			){
		ResultBean1<Pages> result  = new ResultBean1<Pages>();
		return BuildBean1.buildResulttoPages(result, "success", "error",service.getSaleMarginCount1(client,materiel,wagonNumber,trafficUnit,driver,matter_type,shippingUnit,start_time,end_time,page,pageSize));
	}
	/**
	 * 销售逐车明细表导出
	 */
	@GetMapping("/getSalePoundListExport")
	public Object[][] getSalePoundListExport(
			@RequestParam("client")String client,
			@RequestParam("materiel")String materiel,//缺运输单位，物料类型 司机
			@RequestParam("wagonNumber")String wagonNumber,
			@RequestParam("trafficUnit")String trafficUnit,
			@RequestParam("driver")String driver,
			@RequestParam("matter_type")String matter_type,
			@RequestParam("shippingUnit")String shippingUnit,
			@RequestParam("start_time")String start_time,
			@RequestParam("end_time")String end_time
			){
		return  service.getSalePoundListExport(client,materiel,wagonNumber,trafficUnit,driver,matter_type,shippingUnit,start_time,end_time);
	}
	/**
	 * 新销售逐车明细表导出
	 * @param 
	 * @return
	 */
	@RequestMapping(value="getSalePoundListExports",method=RequestMethod.GET)
	public void getPurchUnitCountExports(
			@RequestParam("client")String client,
			@RequestParam("materiel")String materiel,//缺运输单位，物料类型 司机
			@RequestParam("wagonNumber")String wagonNumber,
			@RequestParam("trafficUnit")String trafficUnit,
			@RequestParam("driver")String driver,
			@RequestParam("matter_type")String matter_type,
			@RequestParam("shippingUnit")String shippingUnit,
			@RequestParam("start_time")String start_time,
			@RequestParam("end_time")String end_time,
			HttpServletResponse response) {
	    service.getSalePoundListExports(client,materiel,wagonNumber,trafficUnit,driver,matter_type,shippingUnit,start_time,end_time,response);
	}
	/**
	 * 销售物料统计导出
	 */
	@GetMapping("/getSaleMatterCountExport")
	public Object[][] getSaleMatterCounExportt(
			@RequestParam("client")String client,
			@RequestParam("materiel")String materiel,//缺运输单位，物料类型 司机
			@RequestParam("wagonNumber")String wagonNumber,
			@RequestParam("trafficUnit")String trafficUnit,
			@RequestParam("driver")String driver,
			@RequestParam("matter_type")String matter_type,
			@RequestParam("shippingUnit")String shippingUnit,
			@RequestParam("start_time")String start_time,
			@RequestParam("end_time")String end_time
			){
		return  service.getSaleMatterCountExport(client,materiel,wagonNumber,trafficUnit,driver,matter_type,shippingUnit,start_time,end_time);
	}
	/**
	 * 新销售物料统计导出
	 */
	@RequestMapping(value="getSaleMatterCountExports",method=RequestMethod.GET)
	public void getSaleMatterCounExports(
			@RequestParam("client")String client,
			@RequestParam("materiel")String materiel,//缺运输单位，物料类型 司机
			@RequestParam("wagonNumber")String wagonNumber,
			@RequestParam("trafficUnit")String trafficUnit,
			@RequestParam("driver")String driver,
			@RequestParam("matter_type")String matter_type,
			@RequestParam("shippingUnit")String shippingUnit,
			@RequestParam("start_time")String start_time,
			@RequestParam("end_time")String end_time,
			HttpServletResponse response) {
		  service.getSaleMatterCountExports(client,materiel,wagonNumber,trafficUnit,driver,matter_type,shippingUnit,start_time,end_time,response);
	}
	/**
	 * 销售余量统计导出
	 */
	@GetMapping("/getSaleMarginCountExport")
	public Object[][] getSaleMarginCountExport(
			@RequestParam("client")String client,
			@RequestParam("materiel")String materiel,//缺运输单位，物料类型 司机
			@RequestParam("wagonNumber")String wagonNumber,
			@RequestParam("trafficUnit")String trafficUnit,
			@RequestParam("driver")String driver,
			@RequestParam("matter_type")String matter_type,
			@RequestParam("shippingUnit")String shippingUnit,
			@RequestParam("start_time")String start_time,
			@RequestParam("end_time")String end_time
			){
		return service.getSaleMarginCountExport(client,materiel,wagonNumber,trafficUnit,driver,matter_type,shippingUnit,start_time,end_time);
	}
	/**
	 *新 销售余量统计导出
	 */
	@RequestMapping(value="getSaleMarginCountExports",method=RequestMethod.GET)    
	public void getSaleMarginCountExports(
			@RequestParam("client")String client,
			@RequestParam("materiel")String materiel,//缺运输单位，物料类型 司机
			@RequestParam("wagonNumber")String wagonNumber,
			@RequestParam("trafficUnit")String trafficUnit,
			@RequestParam("driver")String driver,
			@RequestParam("matter_type")String matter_type,
			@RequestParam("shippingUnit")String shippingUnit,
			@RequestParam("start_time")String start_time,
			@RequestParam("end_time")String end_time,
			HttpServletResponse response
			){
		service.getSaleMarginCountExports(client,materiel,wagonNumber,trafficUnit,driver,matter_type,shippingUnit,start_time,end_time,response);
	}
}
